package tech.aistar.service.services.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.aistar.dao.IServicesDao;
import tech.aistar.entity.Services;

import tech.aistar.mapper.services.ServiceMapper;
import tech.aistar.service.services.IServicesService;

import java.util.List;

/**
 * @Author: lya
 * @Description: 本类的作用描述:服务Service层实现类
 * @CreateDate: 2019/9/30
 * @Version: 1.0
 */
@Service
public class ServicesServiceImpl implements IServicesService {

    @Autowired
    private IServicesDao servicesDao;

    @Autowired
    private ServiceMapper serviceMapper;






    /**
     *查询所有服务
     */
    @Override
    public List<Services> findAll() {
        List<Services> list = servicesDao.findAll();
        return list;
    }

    /**
     * 通过服务ID查询
     */
    @Override
    public Services findById(Integer id) {

        return servicesDao.findById(id).get();
    }

    /**
     * 添加服务
     */
    @Override
    public void add(Services services) {
        servicesDao.save(services);
    }

    /**
     * 通过ID删除服务（修改status）
     */
    @Override
    public void updateStatus(Services services) {

        servicesDao.save(services);
    }

    /**
     * 通过ID删除服务
     */
    @Override
    public void delById(Integer id) {
        servicesDao.deleteById(id);
    }

    /**
     * 通过ID修改服务信息
     */
    @Override
    public void modifiy(Services services) {
        servicesDao.save(services);
    }

    @Override
    public List<Services> findByUserInfoId(Integer userinfoId) {
        List<Services> servicesList = serviceMapper.findId(userinfoId);
        return servicesList;
    }

}
